package com.liuning.Thread;

/**
 * 创建线程方式二：实现Runnable接口，重写run方法，执行线程需要丢入实现了Runnable接口的实现类，调用start方法
 */

public class TestThread3 implements Runnable{


    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println("我在写代码 " + i);
        }
    }

    public static void main(String[] args) {
        //创建runnable接口的实现类对象
        TestThread3 thread3 = new TestThread3();

        //创建线程对象，通过线程对象开启线程
        Thread thread = new Thread(thread3);
        thread.start();

        for (int i = 0; i < 20; i++) {
            System.out.println("主线程执行 " + i);
        }

    }
}
